﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel.Composition;
using SoundEdge.Media.Wave;
using SoundEdge.Media.Settings;

namespace SoundEdge.Media.Wave.Plugins
{
    [Export(typeof(IOutputDevicePlugin))]
    public class AsioOutPlugin : IOutputDevicePlugin
    {
        private AsioOutSettings _settings;
        public IOutputSettings Settings
        {
            get { return _settings; }
        }

        public AsioOutPlugin()
        {
            _settings = AsioOutSettings.LoadSettings<AsioOutSettings>("settings.xml");
            if (_settings == null)
            {
                _settings = new AsioOutSettings();
            }
        }

        public IWavePlayer CreateDevice()
        {
            return new AsioOut(_settings.DeviceName);
        }

        public virtual UserControl CreateSettingsPanel()
        {
            throw new NotSupportedException();
        }

        public string Name
        {
            get { return "AsioOut"; }
        }

        public bool IsAvailable
        {
            get { return AsioOut.isSupported(); }
        }

        public int Priority
        {
            get { return 4; }
        }
    }
}
